﻿using System;
using System.CodeDom.Compiler;
using System.Linq;

namespace FBGraph.ClientGenerator.CodeGen
{
    public class CustomAttributeList : CodeGenObjectList<CustomAttribute>
    {
        public CustomAttributeList(params CustomAttribute[] customAttributes) : base(1, customAttributes) { }

        public override void Write(CodeGenWriter writer)
        {
            base.Write(writer);
            if (this.Any()) writer.WriteLine();
        }

        public void Suggest(String name, params Argument[] arguments)
        {
            this.Suggest(new CustomAttribute(name, arguments));
        }

        public void Suggest(Type type, params Argument[] arguments)
        {
            this.Suggest(new CustomAttribute(type, arguments));
        }

        public void Suggest(CustomAttribute customAttribute)
        {
            if (!this.Any(a => a.Name == customAttribute.Name)) this.Add(customAttribute);
        }
    }
}